//@author A0080442N
#include "PreviousAction.h"

PreviousAction::PreviousAction() {
	_previousConfirmTasks.clear();
	_previousCommandType = INVALID;
}

void PreviousAction::updateTask(CommandType command, Task previous, int itemNumber) {
	if (command == ADD_TASK) {
		_previousCommandType = ADD_TASK;
		_previousItemNumber = itemNumber;
	} else if(command == MARK_TASK) {
		_previousCommandType = MARK_TASK;
		_previousItemNumber = itemNumber;
	} else if (command == UNMARK_TASK) {
		_previousCommandType = UNMARK_TASK;
		_previousItemNumber = itemNumber;
	} else if (command == DELETE_TASK || command == EDIT_TASK) {
		_previousCommandType = command;
		_previousTask = previous;
		_previousItemNumber = itemNumber;
	} else if (command == CONFIRM) {
		_previousCommandType = command;
		_previousTask = previous;
		_previousItemNumber = itemNumber;
	}
}

void PreviousAction::clearVector() {
	_previousConfirmTasks.clear();
}

void PreviousAction::addToPreviousConfirmTasks(Task previous) {
	_previousConfirmTasks.push_back(previous);
}

CommandType PreviousAction::getPreviousCommandForUndo() {
	return _previousCommandType;
}

vector<Task> PreviousAction::getPreviousConfirmTasks(){
	return _previousConfirmTasks;
}

Task PreviousAction::getPreviousTask() {
	return _previousTask;
}

int PreviousAction::getPreviousItemNumber() {
	return _previousItemNumber;
}